package com.ljq.cksp.controller;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.ljq.cksp.dao.PartDao;
import com.ljq.cksp.pojo.Result;
import com.ljq.cksp.service.PartService;
import com.ljq.cksp.util.PythonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Author:ljq
 * @Date:2020/4/4
 */
@RestController
@RequestMapping("/predict")
public class PredictController {

    @Autowired
    PartService partService;

    @PostMapping("/accusation")
    public Result accusation(String fact){
        Result result = new Result();
        result.setData(PythonUtil.sendRequest(fact, "accusation"));
        return result;
    }

    @PostMapping("/law")
    public Result relevantArticles(String fact){
        Result result = new Result();
        String str = PythonUtil.sendRequest(fact, "relevant_articles");
        int partNum = Integer.valueOf(str);
        result.setData(partService.findByNums(partNum));
        return result;
    }

    @PostMapping("/imprisonment")
    public Result imprisonment(String fact){
        Result result = new Result();
        result.setData(PythonUtil.sendRequest(fact, "imprisonment"));
        return result;
    }
}
